package com.sm.honkon.ui.fragment.clients_management

import android.os.Bundle
import androidx.core.os.bundleOf
import androidx.lifecycle.observe
import com.sm.honkon.R
import com.sm.honkon.app.base.BaseFragment
import com.sm.honkon.app.handle.BottomHandle
import com.sm.honkon.data.bean.CustomerEntity
import com.sm.honkon.databinding.FrgPersonInfoBinding
import com.sm.honkon.ui.model.PersonInfoViewModel
import kotlinx.android.synthetic.main.frg_person_info.*
import me.hgj.jetpackmvvm.ext.nav
import me.hgj.jetpackmvvm.ext.navigateAction

class PersonInfoFragment :
    BaseFragment<PersonInfoViewModel, FrgPersonInfoBinding>() {
    override fun layoutId(): Int = R.layout.frg_person_info

    override fun initView(savedInstanceState: Bundle?) {
        arguments?.getLong("userId")?.let {
            mViewModel.user = mViewModel.dao.getCustomer(it)
        }
        mDatabind.model = mViewModel
        mDatabind.handle = BottomHandle(nav())
        iv_edit.setOnClickListener {
            nav().navigateAction(R.id.action_personInfoFragment_to_handleClientsInfoFragment,
                bundleOf("user" to mViewModel.user.value)
            )
        }
    }

}